home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d3 / rettig.arc / TRSOURCE.EXE / PEEKBYTE.ASM < prev    next >
Assembly Source File  |  1990-10-22  |  2KB  |  59 lines

  1. ; PEEKBYTE.ASM
  2. ;
  3. ; by Ralph Davis
  4. ; modified by Leonard Zerman
  5. ;
  6. ; Placed in the public domain by Tom Rettig Associates, 10/22/1990.
  7. ;
  8.          PUBLIC   PEEKBYTE
  9.  
  10.          EXTRN    _TR_PEEK_PARMS:FAR
  11.  
  12.          INCLUDE  EXTENDA.MAC
  13.  
  14. ;*****************************************************
  15. PEEKBYTE_TEXT SEGMENT BYTE PUBLIC 'CODE'
  16.          ASSUME   CS:PEEKBYTE_TEXT
  17. ;-----------------------------------------------------
  18. ;     PEEKBYTE(segment, offset)
  19. ;
  20. ;        segment = SPACE(4)    && hexadecimal string
  21. ;        offset  = number < 65536 or hexadecimal string
  22. ;
  23. ;        Returns:  byte at segment:offset as an integer
  24. ;                  -1 if less than two parameters passed
  25. ;--------------
  26. PEEKBYTE PROC     FAR
  27.          PUSH     BP
  28.          MOV      BP,SP
  29.          PUSH     DS
  30.          PUSH     ES
  31.          PUSH     BX
  32.          PUSH     SI
  33.          CALL     _TR_PEEK_PARMS
  34.          JL       PEEKBYTE_ERR   ; Sign flag set means less than 2 parms
  35.          MOV      DS,SI          ; Segment address returned in SI--
  36.                                  ; move it to DS
  37.          MOV      SI,AX          ; Offset address returned in AX--
  38.                                  ; move it to SI
  39.                                  ; DS:SI now points to desired byte
  40.          MOV      AL,[SI]        ; pick it up
  41.          CBW                     ; extend the sign
  42.          JMP      SHORT PEEKBYTE_EXIT   ; and we're done
  43. PEEKBYTE_ERR:
  44.          MOV      AX,-1          ; return -1 for error condition
  45.  
  46. PEEKBYTE_EXIT:
  47.          POP      SI
  48.          POP      BX
  49.          POP      ES
  50.          POP      DS
  51.          POP      BP
  52.          RET_INT  AX             ; return an integer to caller
  53.          RET
  54. PEEKBYTE ENDP
  55. ;------------------------------------------------
  56. PEEKBYTE_TEXT    ENDS
  57. ;************************************************
  58.          END
  59.